package com.multiple.sources.core.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.multiple.sources.core.config.DbContextHolder;
import com.multiple.sources.core.servie.api.IUserService;

/**
 * 前端控制器
 *
 */
@Controller
@RequestMapping("/user")
public class UserController {

	
	@Autowired 
	private IUserService userService;
	
    
    private Logger logger = Logger.getLogger(getClass());
	
	
	@RequestMapping(value="/list",method={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public Object list() {
		logger.info("查询所有的用户");
		System.out.println(" UserController  当前数据源："+DbContextHolder.getDBType());
		 return userService.selectAll();
	}
	
	@RequestMapping(value="/db",method={RequestMethod.GET,RequestMethod.POST})
	@ResponseBody
	public Object infofindDbContextHolder(){
		return DbContextHolder.dataSources();
		
	}
}
